package com.msb.apidriver.service;

import com.msb.apidriver.feign.ServiceDriverUserClient;
import com.msb.apidriver.feign.TerminalClient;
import com.msb.commons.dto.ApiDriverPointRequest;
import com.msb.commons.dto.Car;
import com.msb.commons.dto.PointDTO;
import com.msb.commons.response.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: chshh
 * @version: 1.0
 */
@Service
public class PointService {
    @Autowired
    private ServiceDriverUserClient serviceDriverUserClient;
    @Autowired
    private TerminalClient terminalClient;
    public ResponseResult upload(ApiDriverPointRequest apiDriverPointRequest){
        //获取carID
        Long carId = apiDriverPointRequest.getCarId();
        //通过carId获取tid,trid  调用service-driver-user的接口
        ResponseResult<Car> ResponseResult = serviceDriverUserClient.getCarById(carId);
        String tid = ResponseResult.getData().getTid();
        String trid = ResponseResult.getData().getTrid();
        //调用地图去上传
        PointDTO pointDTO = new PointDTO();
        pointDTO.setTid(tid);
        pointDTO.setTrid(trid);
        pointDTO.setPoints(apiDriverPointRequest.getPoints());

        return terminalClient.upload(pointDTO);
    }
}
